'use strict';

let nunjucks = require('nunjucks');

function getEnv(path,opts){
    path = path || 'views';
    opts = opts || {};
    return nunjucks.configure('views',opts);
};

module.exports = async (ctx,next)=>{
    ctx.render = function(views,obj){
        let env = getEnv();
        ctx.body = env.render(views,obj);
    }
    await next();
}